<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>斐波那契数列</title>
    <script>
      function feibo(pos) {
        let n1 = 1,
          n2 = 1,
          result = 1

        for (let i = 2; i < pos; i++) {
          result = n1 + n2
          n1 = n2
          n2 = result
        }
        return result
      }

      let pos = prompt('请您输入斐波那契数列数字的位置: ')
      let result = feibo(pos)
      alert(`斐波那契第${pos}位的值为: ${result}.`)
    </script>
  </head>
  <body></body>
</html>
